{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"contentcontainer med left\" style=\"margin-left: -50px;\">\n",
    "<dl class=\"dl-horizontal\">\n",
    "  <dt>Title</dt> <dd> Surface Element</dd>\n",
    "  <dt>Dependencies</dt> <dd>Matplotlib</dd>\n",
    "  <dt>Backends</dt> <dd><a href='../matplotlib/Surface.ipynb'>Matplotlib</a></dd>\n",
    "\n",
    "</dl>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "hv.extension('matplotlib')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "``Surface`` is used for a set of gridded points whose associated value dimension represents samples from a continuous surface. ``Surface`` is equivalent to an ``Image`` type and supports all the same data formats, including simply NumPy arrays with associated ``bounds`` and other gridded data formats such as xarray.\n",
    "\n",
    "Rendering a large can often be quite expensive, using ``rstride`` and ``cstride`` we can draw a coarser surface. We can also control the ``azimuth``, ``elevation`` and ``distance`` as plot options to control the camera angle:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%opts Surface [azimuth=30 elevation=30] (cmap='plasma' rstride=20, cstride=2)\n",
    "hv.Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to a simple surface plots, the matplotlib surface plot also supports other related ``plot_type`` modes including ``'wireframe'`` and ``'contour'`` plots:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%opts Surface [azimuth=60] (cmap='fire' linewidth=1 edgecolor='black') Layout [fig_size=150 hspace=0.1]\n",
    "xs = np.arange(-4, 4, 0.25)\n",
    "ys = np.arange(-4, 4, 0.25)\n",
    "X, Y = np.meshgrid(xs, ys)\n",
    "R = np.sqrt(X**2 + Y**2)\n",
    "Z = np.sin(R)\n",
    "surface = hv.Surface((xs, ys, Z))\n",
    "surface + surface.opts(plot=dict(plot_type='wireframe')) + surface.opts(plot=dict(plot_type='contour'))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
